<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
int flag = 0;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
    <meta charset="utf-8"/>
    <base href="<%=basePath%>">
    <title>我的地址</title>
    <meta name="viewport" content="width=1000"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/moban.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/common/reset.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/common/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/common/xm.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/common/sui_css.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/common/common.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/zhanghbd_first.css"/>
</head>
<body>
<jsp:include page="../top.jsp"></jsp:include>
<div class="wrap">
    
    <!--头部部分-->
    <div class="cus_navigation">
        <div class="nav_con">
            <p>
                <a href="">首页</a> >
                <a href="">我的不二定制</a> >
                <a href="">我的账户</a> >
                <a href="">我的地址</a>
            </p>
        </div>
    </div>
    <div class="cus_content">
        <div class="xian"></div>
        
        <jsp:include page="../dingdan.jsp"></jsp:include>
        
        <!--右边代码块，注意大类的命名-->
        <div class="cus_content_right fl">
            <!--账户绑定-->
            <div class="content-zhanghbd ddz">
                <h2 class="zhanghbd_title woddz">我的地址</h2>
                <button class="input_btn_kong btn_32 woddz"><span id="jiahao">+</span>新增地址</button>
                <div class="content_content woddz kuandu">

                    <table class="table table-striped">
                        <thead>
                        <th>收货人</th>
                        <th>所在地区</th>
                        <th>详细地址</th>
                        <th>邮编</th>
                        <th>手机/电话</th>
                        <th>操作</th>
                        <th></th>
                        </thead>
                        <tbody id="showview">
                        	<c:if test="${!empty addresslist}">
                        		<c:forEach items="${addresslist }" var="addresslist" >
                        			<tr>
			                            <td><span>${addresslist.consignee }</span></td>
			                            <td><span>${addresslist.region_province }${addresslist.region_city }${addresslist.region_area }</span></td>
			                            <td><span>${addresslist.detailed_add }</span></td>
			                            <td><span>${addresslist.zip_code }</span></td>
			                            <td><span>${addresslist.address_telephone }</span></td>
			                            <td>
			                                <a class="woddz_xiugai" onclick="modify(this,${addresslist.address_id})">修改</a><span>|</span>
			                                <a class="woddz_shanchu" onclick="delete1(${addresslist.address_id })">删除</a>
			                            </td>
			                            <td>
			                           <%
			                           	if(flag==0){
			                            %>
			                            	<a class="dizhi kuang">默认地址</a>	
			                            	                            	
			                           <%
			                           	flag=1;			}else{
			                           
			                            %>
			                            	<a class="dizhi">设置默认</a>
			                            
			                             <%} %> 
			                            </td>
			                            
			                        </tr>            
                        		</c:forEach>
	                        </c:if>    
                        </tbody>
                    </table>
                    <div class="clear"></div>
                    <!--分页器-->
                    <div class="sui-pagination pagination-right pagination-small">
                        <ul>
                            <li class="dotted"><span>共<span id="zongji">18</span>笔订单</span></li>
                            <li class="prev disabled"><a href="#">&lt;</a></li>
                            <li class="activebaba"><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li class="dotted"><span>...</span></li>
                            <li class="next"><a href="#">&gt;</a></li>
                            <li class="dotted"><span>跳至</span></li>
                            <li class="yema"><a><input type="text"/>页</a></li>
                            <li><a><input type="button" value="跳转"/></a></li>
                        </ul>
                    </div>
                    <!--结束-->
                </div>

            </div>
        </div>
    </div>
    <div class="clear"></div>
    
    <jsp:include page="../footer.jsp"></jsp:include>
   
   
    
    <div class="wodzz1_mask" id="shanchu1">
        <div class="o5_mask">
            <span id="o5_dele">X</span>
            <p id="querenshanchu">确认收货后，订单将变为交易成功。</p>
            <a>
                <button id="o5_ok" class="input_btn_shi btn_175">确认</button>
                <button id="o5_no" class="input_btn_shi btn_175">取消</button>
            </a>
        </div>
    </div>
    <div class="wodzz1_mask" id="shanchu2">
        <div class="o5_mask">
            <span id="chacha">X</span>
            <p id="shanchuchenggong">删除成功</p>
            <a></a>
        </div>
    </div>
    <div class="woddz_mask">
        <div class="o5_mask">
            <div class="title">
                <p><a>新增地址</a><span id="mask_x">X</span></p>
            </div>
            <form action="" method="post">
	            <div class="gwlc4">
	                <span class="fl suozaidiqu"><sub>*</sub>所在地区:</span>
	                <div class="select first clearfix">
	                    <div class="xm_select">
	                        <input type="text" placeholder="请选择省份" readonly name="region_province" id="region_province"/>
	                        <a class="iconfont icon-xialajiantou"></a>
	                    </div>
	                    <div class="xm_show">
	                        <ul id="pro">
	
	                        </ul>
	                    </div>
	                </div>
	                <div class="select clearfix">
	                    <div class="xm_select">
	                        <input type="text" placeholder="请选择城市" readonly name="region_city" id="region_city"/>
	                        <a class="iconfont icon-xialajiantou"></a>
	                    </div>
	                    <div class="xm_show">
	                        <ul id="city">
	                        </ul>
	                    </div>
	                </div>
	                <div class="select clearfix">
	                    <div class="xm_select">
	                        <input type="text" placeholder="选择区" readonly name="region_area" id="region_area"/>
	                        <a class="iconfont icon-xialajiantou"></a>
	                    </div>
	                    <div class="xm_show">
	                        <ul id="direct">
	
	                        </ul>
	                    </div>
	                </div>
	                <div class="clear"></div>
	                <span class="xiangxixinxi"><sub>*</sub>详细地址:</span>
	                <textarea name="detailed_add" id="detailed_add" rows="" maxlength="100" placeholder="请填写详细地址"></textarea>
	                <span class="baifenbai"><a>0</a>/100</span>
	                <p class="tishi">建议您如实填写详细收货地址,例如街道名称，门牌号码，楼层和房间号等信息</p>
	                <div class="clear"></div>
	                <span class="youbian fl">邮编地址:</span>
	                <input type="text" class="input_text text_138 fl" id="youbiandizhi" name="zip_code"/>
	                <span class="youdiquhao fl">如您不清楚邮递区号，请填写000000</span>
	                <div class="clear"></div>
	                <span class="shouhuo fl"><sub>*</sub>收货人姓名:</span>
	                <input type="text" class="input_text text_138 shouhuo_text_138 fl" name="consignee" id="consignee"/>
	                <div class="clear"></div>
	                <span class="fl shoujihaoma">手机号码:</span>
	                <div class="select clearfix first">
	                    <div class="xm_select">
	                        <input type="text" value="中国大陆+86" readonly/>
	                        <a class="iconfont icon-xialajiantou"></a>
	                    </div>
	                    <div class="xm_show">
	                        <ul>
	                            <li>中国大陆+86</li>
	                            <li>香港</li>
	                            <li>台湾</li>
	                            <li>澳门</li>
	                        </ul>
	                    </div>
	                </div>
	                <input type="text" class="input_text text_223" name="address_telephone" id="address_telephone"/>
	                <div class="clear"></div>
	                <span class="fl dianhuahaoma">电话号码:</span>
	                <div class="select clearfix first">
	                    <div class="xm_select">
	                        <input type="text" value="中国大陆+86" readonly/>
	                        <a class="iconfont icon-xialajiantou"></a>
	                    </div>
	                    <div class="xm_show">
	                        <ul>
	                            <li>中国大陆+86</li>
	                            <li>香港</li>
	                            <li>台湾</li>
	                            <li>澳门</li>
	                        </ul>
	                    </div>
	                </div>
	                <input type="text" class="input_text text_80" placeholder="区号" maxlength="6"/>
	                <a>-</a><input type="text" class="input_text text_120" placeholder="电话号码" maxlength="10"/>
	                <a>-</a><input type="text" class="input_text text_80" placeholder="分机" maxlength="6"/>
	                <p class="yizhi">手机号码和电话号码必须填一项</p>
	                <button class="input_btn_shi btn_184" id="baocun">保存收货人信息</button>
	                <label for="changyong"><input type="checkbox" id="changyong" class="shouhuoright"/><span
	                        class="changyong">添加常用地址</span></label>
	            </div>
	        </form>
        </div>
    </div>
</div>
<script src="<%=basePath%>js/common/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>js/wo_ddz.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>js/common/xm.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>js/common/DistrictJson.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>js/common/proJson.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>js/common/CityJson.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#baocun").click(function(){
				
				
				var region_province = document.getElementById("region_province").value;
				var region_city = document.getElementById("region_city").value;
				var region_area = document.getElementById("region_area").value;
				var detailed_add = document.getElementById("detailed_add").value;
				var zip_code = document.getElementById("youbiandizhi").value;
				var consignee = document.getElementById("consignee").value;
				var address_telephone = document.getElementById("address_telephone").value;


				$.ajax({
					url:"address.do?type=add",
					type:"POST",
					dataType:"JSON",
					data:{region_province:region_province,region_city:region_city,region_area:region_area,detailed_add:detailed_add,zip_code:zip_code,consignee:consignee,address_telephone:address_telephone},
					success:function(data){
						if(data.code=="0"){
							inner(data);
						}
					},
					error:function(){
						
					}
				});
			
			});
		});
		
		function delete1(address_id){
			
		}
		
		function inner(data){
			$("#showview").empty(); 
			var str = "";
			var flag = 0;
			$.each(data.edulist,function(idnex,obj){
				if(flag==0){
					str = str+"<tr><td><span>"+obj.consignee+"</span></td>"+
			          "<td><span>"+obj.region_province+obj.region_city+obj.region_area+"</span></td>"+
			           "<td><span>"+obj.detailed_add+"</span></td>"+
			           "<td><span>"+obj.zip_code +"</span></td>"+
			           "<td><span>"+obj.address_telephone+"</span></td>"+
			            "<td><a class='woddz_xiugai' onclick='modify(this,"+obj.address_id+")'>修改</a><span>|</span>"+
			             "<a class='woddz_shanchu' onclick='delete1("+obj.address_id+")''>删除</a>"+              
			            "</td><td><a class='dizhi kuang'>默认地址</a></td> </tr>";
			            flag =1;
				}else{
					str = str+"<tr><td><span>"+obj.consignee+"</span></td>"+
			          "<td><span>"+obj.region_province+obj.region_city+obj.region_area+"</span></td>"+
			           "<td><span>"+obj.detailed_add+"</span></td>"+
			           "<td><span>"+obj.zip_code +"</span></td>"+
			           "<td><span>"+obj.address_telephone+"</span></td>"+
			            "<td><a class='woddz_xiugai' onclick='modify(this,"+obj.address_id+")'>修改</a><span>|</span>"+
			             "<a class='woddz_shanchu' onclick='delete1("+obj.address_id+")''>删除</a>"+              
			            "</td><td><a class='dizhi'>设置默认</a></td> </tr>";
				}
			});
			document.getElementById("showview").innerHTML = str;
		}
	</script>
</body>

</html>